{include file="public/head"}

<body>
<div id="wrapper">
    {include file="public/menu"}

    <div id="page-wrapper" class="gray-bg dashbard-1">
        {include file="public/nav"}
        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-10">
                <h2>会员信息</h2>
                <ol class="breadcrumb">
                    <li>
                        <a href="{:url('Index/index')}">主页</a>
                    </li>
                    <li>
                        <a>会员</a>
                    </li>
                    <li>
                        <strong>会员列表</strong>
                    </li>
                </ol>
            </div>
            <div class="col-lg-2">

            </div>
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>会员信息列表</h5>
                            <div class="ibox-tools">
                                <small>共 {$Count} 条</small>
                            </div>
                        </div>

                        <div class="ibox-content">
                            <form method="get" action="{:url('User/UserList')}">
                            <div class="row">
                                <div class="col-sm-3 m-b-xs">
                                    <div class="row">
                                        <div class="col-sm-2 m-b-xs"></div>
                                        <div class="col-sm-3 m-b-xs">会员级别</div>
                                        <div class="col-sm-7 m-b-xs">
                                            <select class="input-sm form-control input-s-sm inline" id="level" name="level">
                                                <option value="0">全部</option>
                                                {volist name="LevelList" id="vv"}
                                                <option value="{$vv.id}" {if condition="$Data.level eq $vv.id"}selected{/if}>{$vv.name}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                    </div>
                                </div>

                                <div class="col-sm-3 m-b-xs">
                                    <div class="row">
                                        <div class="col-sm-2 m-b-xs"></div>
                                        <div class="col-sm-3 m-b-xs">会员姓名</div>
                                        <div class="col-sm-7 m-b-xs">
                                            <input type="text" class="input-sm form-control input-s-sm inline" id="name" name="name" value="{$Data.name|default=''}">
                                        </div>
                                    </div>
                                </div>

                                <div class="col-sm-3 m-b-xs">
                                    <div class="row">
                                        <div class="col-sm-2 m-b-xs"></div>
                                        <div class="col-sm-3 m-b-xs">会员手机</div>
                                        <div class="col-sm-7 m-b-xs">
                                            <input type="text" class="input-sm form-control input-s-sm inline" id="phone" name="phone" value="{$Data.phone|default=''}">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-3 m-b-xs">
                                    <div class="row">
                                        <div class="col-sm-2 m-b-xs"></div>
                                        <div class="col-sm-3 m-b-xs">会员id</div>
                                        <div class="col-sm-7 m-b-xs">
                                            <input type="text" class="input-sm form-control input-s-sm inline" id="id" name="id" value="{$Data.id|default=''}">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-3 m-b-xs">
                                    <div class="row">
                                        <div class="col-sm-2 m-b-xs"></div>
                                        <div class="col-sm-3 m-b-xs">会员账号</div>
                                        <div class="col-sm-7 m-b-xs">
                                            <input type="text" class="input-sm form-control input-s-sm inline" id="username" name="username" value="{$Data.username|default=''}">
                                        </div>
                                    </div>
                                </div>

                                <div class="col-sm-3 m-b-xs">
                                    <div class="row">
                                        <div class="col-sm-2 m-b-xs"></div>
                                        <div class="col-sm-3 m-b-xs">开始时间</div>
                                        <div class="col-sm-7 m-b-xs">
                                            <input type="datetime-local" class="input-sm form-control input-s-sm inline" id="begin_time" name="begin_time" value="{$Data.begin_time|default=''}">
                                        </div>
                                    </div>
                                </div>

                                <div class="col-sm-3 m-b-xs">
                                    <div class="row">
                                        <div class="col-sm-2 m-b-xs"></div>
                                        <div class="col-sm-3 m-b-xs">结束时间</div>
                                        <div class="col-sm-7 m-b-xs">
                                            <input type="datetime-local" class="input-sm form-control input-s-sm inline" id="end_time" name="end_time" value="{$Data.end_time|default=''}">
                                        </div>
                                    </div>
                                </div>

                                <div class="col-sm-3 m-b-xs">
                                    <div class="row">
                                        <div class="col-sm-12 m-b-xs">
                                            <button class="btn btn-sm btn-primary" type="submit" id="search"><i class="fa fa-search"></i> 搜索</button>
                                            <!--<button class="btn btn-sm btn-success" type="submit" id="export">导出Excel</button>-->
                                            <a class="btn btn-sm btn-danger" href="javascript:;" onclick="user_add('新增会员','{:url("User/UserAdd")}','1000','570')">新增会员</a>
                                            <a class="btn btn-sm btn-warning" href="javascript:;" onclick="user_recommendmap('推荐图表','{:url("User/RecommendMap")}','1000','570')">推荐图表</a>
<!--                                            <a class="btn btn-sm btn-warning" href="javascript:;" onclick="user_netmap('网络图表','{:url("User/NetMap")}','1000','570')">网络图表</a>-->

<!--                                            <a class="btn btn-sm btn-warning" href="javascript:;" onclick="user_import('会员导入','{:url("User/UserImport")}','800','282')">会员导入</a>-->
<!--                                            <a class="btn btn-sm btn-danger"  id="settlement">关系生成</a>-->
                                        </div>
                                    </div>
                                </div>
                            </div>
                            </form>
                            <div class="table-responsive">
                                <table class="table table-hover">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>会员账号</th>
                                        <th>会员头像</th>
                                        <th>会员级别</th>
                                        <!--<th>等级</th>-->
                                        <th>会员姓名</th>
                                        <th>手机号码</th>
                                        <th>推荐账号</th>
                                        <th>业绩</th>
                                        <th>余额</th>
                                        <th>积分</th>
                                        <th>区域代理</th>
                                        <th>管理区域</th>
                                        <th>备注信息</th>
                                        <th>加入时间</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {volist name="UserList" id="v"}
                                    <tr>
<!--                                        <td>{$key+1}</td>-->
                                        <td>{$v.id}</td>
                                        <td>{$v.username}</td>
                                        <td><img src="{$v.head_url}" style="width:40px;height:40px;"/></td>
                                        <td>{$v.level}</td>
                                        <!--<td>{if condition="$v.level_up eq 1"}创业合伙人{elseif condition="$v.level_up eq 2"}联合创始人{else/}用户{/if}</td>-->
                                        <td>{$v.name}</td>
                                        <td>{$v.phone}</td>
                                        <td>{$v.recommend}</td>
                                        <td>{$v.team_num}</td>
                                        <!--<td>{$v.person_achievement}</td>-->
                                        <td><a title="点击修改余额" href="javascript:;" onclick="user_balance('余额修改','{:url("User/UserBalance",["id"=>$v["id"],'type'=>4])}','800','395')" >{$v.balance_4} </a></td>
                                        <td><a title="点击修改积分" href="javascript:;" onclick="user_balance('积分修改','{:url("User/UserBalance",["id"=>$v["id"],'type'=>1])}','800','395')" >{$v.balance_1} </a></td>
                                        <!--<td>{$v.team_num} </td>-->
                                        <td>{if condition="$v.level_1 eq 0"}不是{elseif condition="$v.level_1 eq 1"}区县经理{elseif condition="$v.level_1 eq 2"}市总监{elseif condition="$v.level_1 eq 3"}省总监{/if}</td>
                                        <td>{if condition="$v.quyu eq ''"}无{else}{$v.quyu}{/if}</td>
                                        <td>
                                            <span style="text-overflow: ellipsis;white-space: nowrap;overflow: hidden;width: 50px;display: block">{$v.remark}</span>
                                        </td>
                                        <td>{$v.add_time|date="Y-m-d H:i",###}</td>
                                        <td>
                                            
                                            <a title="信息编辑" href="javascript:;" class="btn btn-xs btn-info" onclick="user_edit('信息编辑','{:url("User/UserEdit",["id"=>$v["id"]])}','800','428')">编辑</a>
<!--                                            <a title="信息编辑" href="javascript:;" class="btn btn-xs btn-info" onclick="user_edit('信息编辑','{:url("User/UserEdit",["id"=>$v["id"]])}','800','428')">删除</a>-->

                                            <a title="登录前台" href="javascript:;" class="btn btn-xs btn-success" onClick="user_login(this,{$v.id})">登录</a>
                                            <a title="重置密码" href="javascript:;" class="btn btn-xs btn-danger" onClick="user_pas(this,{$v.id})">密码重置</a>
                                            {if condition="$v.status eq 1"}
                                            <a title="冻结用户" href="javascript:;" class="btn btn-xs btn-danger" onClick="user_dong(this,{$v.id})">冻结用户</a>
                                            {else/}
                                            <a title="激活用户" href="javascript:;" class="btn btn-xs btn-success" onClick="user_ji(this,{$v.id})">激活用户</a>
                                            {/if}
                                            <a title="会员删除" href="javascript:;" onClick="user_del(this,{$v.id})"><i class="fa fa-trash text-navy"></i></a>
                                        </td>
                                    </tr>
                                    {/volist}
                                    </tbody>
                                </table>
                            </div>
                            <div class="row" style="text-align: center">
                                {$Page}
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
        {include file="public/foot"}

    </div>
</div>
</div>
{include file="public/footer"}
<script>
    /*会员-添加*/
    function user_add(title,url,w,h){
        layer_show(title,url,w,h);
    }

    /*网络图表*/
    function user_netmap(title,url,w,h){
        layer_show(title,url,w,h);
    }

    /*推荐图表*/
    function user_recommendmap(title,url,w,h){
        layer_show(title,url,w,h);
    }


    /*会员-导入*/
    function user_import(title,url,w,h){
        layer_show(title,url,w,h);
    }

    /*条件搜索*/
    var searchurl = "{:url('User/UserList')}";
    $('#search').click(function () {

        $('form').attr('action',searchurl);
    });

    /*Excel导出*/
    var exporturl = "{:url('User/UserExport')}";
    $('#export').click(function () {

        $('form').attr('action',exporturl);
    });

    /*业绩结算*/
    $('#settlement').click(function(){
        $.ajax({
            type:'post',
            dataType:'json',
            url:"{:url('User/UserSettlement')}",
            data:'',
            beforeSend: function() {
                layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                })
            },
            success:function (data){
                layer.closeAll()
                if(data.status == 1){
                    layer.msg(data.message,{icon: 6,time:1500},function () {
                        window.top.location.reload();
                    });
                }else{
                    layer.msg(data.message,{icon: 5,time:1500});
                }
            },
            error: function (err) {
                layer.closeAll()
                console.log(err)
            }
        })
    })

    /*会员-余额*/
    function user_balance(title,url,w,h){
        layer_show(title,url,w,h);
    }

    /*会员-编辑*/
    function user_edit(title,url,w,h){
        layer_show(title,url,w,h);
    }

    /*会员-状态*/
    function user_status(obj,id){
        layer.confirm('确认要激活吗？',function(index){
            $.ajax({
                type:"post",
                url:"{:url('User/UserStatus')}",
                data:{
                    id:id,
                },
                dataType:"json",
                success:function(data){
                    if(data.status == 1){
                        layer.msg(data.message,{icon: 6,time:1500},function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg(data.message,{icon: 5,time:1500});
                    }
                }
            });
        });
    }

    /*密码-重置*/
    function user_pas(obj,id){
        layer.confirm('确认要重置密码吗？',function(index){
            $.ajax({
                type:"post",
                url:"{:url('User/UserPassword')}",
                data:{
                    id:id,
                },
                dataType:"json",
                success:function(data){
                    if(data.status == 1){
                        layer.msg(data.message,{icon: 6,time:1500},function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg(data.message,{icon: 5,time:1500});
                    }
                }
            });
        });
    }
    
    /*冻结用户*/
    function user_dong(obj,id){
        layer.confirm('确认要冻结用户吗？',function(index){
            $.ajax({
                type:"post",
                url:"{:url('User/userdong')}",
                data:{
                    id:id,
                },
                dataType:"json",
                success:function(data){
                    if(data.status == 1){
                        layer.msg(data.message,{icon: 6,time:1500},function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg(data.message,{icon: 5,time:1500});
                    }
                }
            });
        });
    }
    
    /*激活用户*/
    function user_ji(obj,id){
        layer.confirm('确认要激活用户吗？',function(index){
            $.ajax({
                type:"post",
                url:"{:url('User/userji')}",
                data:{
                    id:id,
                },
                dataType:"json",
                success:function(data){
                    if(data.status == 1){
                        layer.msg(data.message,{icon: 6,time:1500},function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg(data.message,{icon: 5,time:1500});
                    }
                }
            });
        });
    }

    /*管理-删除*/
    function user_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type:"post",
                url:"{:url('User/UserDelete')}",
                data:{
                    id:id,
                },
                dataType:"json",
                success:function(data){
                    if(data.status == 1){
                        layer.msg(data.message,{icon: 6,time:1500},function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg(data.message,{icon: 5,time:1500});
                    }
                }
            });
        });
    }

    /*会员-登录*/
    function user_login(obj,id){
        $.ajax({
            type:"post",
            url:"{:url('User/UserLogin')}",
            data:{
                id:id,
            },
            dataType:"json",
            success:function(data){
                if(data.status == 1){
                    layer.msg(data.message,{icon: 6,time:1500},function () {
                        window.open("/index.php/index/app");
                    });
                }else{
                    layer.msg(data.message,{icon: 5,time:1500});
                }
            }
        });
    }

</script>
</body>
</html>
